package com.leetcode.partition16;

public class LC1518换酒问题 {
    
    public static int numWaterBottles(int numBottles, int numExchange) {
        if (numBottles < numExchange) return numBottles;
        int answer = numBottles;
        while (numBottles >= numExchange) {
            int t = numBottles / numExchange;
            answer += t;
            numBottles %= numExchange;
            numBottles += t;
        }
        return answer;
    }

    public static void main(String[] args) {
        System.out.println(numWaterBottles(2, 4));
    }
}
